package com.yms.controller;


import com.yms.pojo.Company;
import com.yms.pojo.PageResult;
import com.yms.pojo.Result;
import com.yms.service.ICompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.util.resources.LocaleData;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2020-03-20
 */
@Controller
@RequestMapping("/company")
public class CompanyController {
    @Autowired
    private ICompanyService companyService;
    @ResponseBody
    @RequestMapping("companyInfo")
    public PageResult<Company> companyInfo(Integer page, Integer rows,Company companyCondition){
        PageResult <Company> result = companyService.selectMore(page,rows,companyCondition);
        return result;
    }
    @ResponseBody
    @RequestMapping("addCompany")
    public Result addCompany(Company company){
        company.setStatus("1");
        company.setStarttime(LocalDateTime.now());
        company.setOrdernumber(0);
        boolean insert = company.insert();
        return new Result(insert,insert?"增加成功":"增加失败");
    }
    //编辑公司状态,与修改其他信息公用此方法
    @RequestMapping("accountStatus")
    @ResponseBody
    public Result accountStatus(Company company){
        boolean b = companyService.updateById(company);
        return new Result(b,b?"修改成功":"修改失败");
    }

    //公司注册实现
    @RequestMapping("reg")
    @ResponseBody
    public Integer reg(Company company){
        return companyService.reg(company);
    }

}

